<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="Mosaddek">
    <meta name="keyword" content="FlatLab, Dashboard, Bootstrap, Admin, Template, Theme, Responsive, Fluid, Retina">
    <link rel="shortcut icon" href="img/favicon.png">

    <title>Quản lý User</title>

    <!-- Bootstrap core CSS -->
    <link href="<?php echo base_url() ?>Resources/Admin/css/bootstrap.min.css" rel="stylesheet">
    <link href="<?php echo base_url() ?>Resources/Admin/css/bootstrap-reset.css" rel="stylesheet">
    <!--external css-->
    <link href="<?php echo base_url() ?>Resources/Admin/assets/font-awesome/css/font-awesome.css" rel="stylesheet" />
    <link href="<?php echo base_url() ?>Resources/Admin/assets/advanced-datatable/media/css/demo_page.css" rel="stylesheet" />
    <link href="<?php echo base_url() ?>Resources/Admin/assets/advanced-datatable/media/css/demo_table.css" rel="stylesheet" />
    <!-- Custom styles for this template -->
    <link href="<?php echo base_url() ?>Resources/Admin/css/style.css" rel="stylesheet">
    <link href="<?php echo base_url() ?>Resources/Admin/css/style-responsive.css" rel="stylesheet" />

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 tooltipss and media queries -->
    <!--[if lt IE 9]>
      <script src="js/html5shiv.js"></script>
      <script src="js/respond.min.js"></script>
    <![endif]-->
  </head>

  <body>

  <section id="container" class="">
      <!--header start-->
      <header class="header white-bg">
          <?php $this->load->view('admin_layout/header') ?>
      </header>
      <!--header end-->
      <!--sidebar start-->
      <aside>
          <div id="sidebar"  class="nav-collapse ">
              <!-- sidebar menu start-->
              <?php $this->load->view('admin_layout/sidebar') ?>
              <!-- sidebar menu end-->
          </div>
      </aside>
      <!--sidebar end-->
      <!--main content start-->
      <section id="main-content">
          <section class="wrapper">
              <!-- page start-->
              <div class="row">
                  <div class="col-lg-12">
                      <section class="panel">
                          <header class="panel-heading">  <?php      if($this->session->userdata('role') == 1) { ?>
                                <a href="#myModal_them" data-toggle="modal" class="btn btn-round btn-info">
                                    Thêm User mới
                                         </a>  
                                         <div aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" id="myModal_them" class="modal fade">
                                  <div class="modal-dialog">
                                      <div class="modal-content">
                                          <div class="modal-header">
                                              <button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
                                              <h4 class="modal-title">Thêm User</h4>
                                          </div>
                                          <div class="modal-body">
                                            <form action="<?php
                                                          //name hero, rarity, type, image , price
                                                          echo base_url('account/add_new_account');
                                                          ?>" method="POST" role="form">
                                                          <div>
                                                          
                                                          <div class="col-lg-6">
                                                  <div class="form-group">
                                                      <label for="username">UserName:</label>
                                                      <input type="text" class="form-control" id="username" name="username" placeholder="Tên User" />
                                                  </div>
                                                  <div class="form-group">
                                                      <label for="password">Password:</label>
                                                      <input type="password" class="form-control" id="password" name="password" placeholder="" />
                                                  </div>
                                                  <div class="form-group">
                                                  <label for="role">Role:</label>
                                                      <select id="role" class="form-control" name="role">
                                                            <?php  if(isset($quyen)) { 
                                                                foreach($quyen as $q) {
                                                                ?>
                                                            <option value="<?php echo $q->ROLE_ID ?>">  <?php echo $q->ROLE_NAME ?></option>
                                                            <?php } } ?>
                                                          </select>
                                                  </div>
                                                  
                                                  <div class="form-group">
                                                      <label for="fullname">Tên đầy đủ:</label>
                                                      <input type="text" class="form-control" id="fullname" name="fullname" placeholder="Họ tên" />
                                                  </div>
                                                    <div class="form-group">
                                                      <label for="address">Địa chỉ liên hệ:</label>
                                                      <input type="text" class="form-control" id="address" name="address" placeholder="Địa chỉ" />
                                                  </div>
                                                  
                                                  <div class="form-group">
                                                      <label for="phone">Điện thoại:</label>
                                                      <input type="text" class="form-control" id="phone" name="phone" placeholder="Phone" />
                                                  </div>
                                                  </div>
                                                  
                                                  <div class="col-lg-6">
                                                  <div class="form-group">
                                                      <label for="email">Email:</label>
                                                      <input type="email" class="form-control" id="email" name="email" placeholder="Email" />
                                                  </div>
                                                  
                                                  <div class="form-group">
                                                      <label for="facebook">Facebook:</label>
                                                      <input type="text" class="form-control" id="facebook" name="facebook" placeholder="facebook" />
                                                  </div>
                                                  
                                                  <div class="form-group">
                                                      <label for="steamprofile">Steam profile:</label>
                                                      <input type="text" class="form-control" id="steamprofile" name="steamprofile" placeholder="profile" />
                                                  </div>
                                                  
                                                  <div class="form-group">
                                                      <label for="steamurl">Steam Offer URL:</label>
                                                      <input type="text" class="form-control" id="steamurl" name="steamurl" placeholder="offer" />
                                                  </div>
                                                  
                                                
                                                  
                                                  <div class="form-group">
                                                      <label for="avatar">Image URL:</label>
                                                      <input type="text" class="form-control" id="avatar" name="avatar" placeholder="Link" />
                                                  </div>
                                                  <div class="form-group">
                                                      <label for="wallet">Wallet</label>
                                                      <input type="text" class="form-control" id="wallet" disabled name="wallet" value="Sẽ được update sau" />
                                                  </div>
                                                  </div>
                                                  </div>

                                                   <input type="hidden" name="url1" value="<?php echo current_url() ?>" />
                                                  <button type="submit" onClick="alert('Thêm user thành công')" class="btn btn-info">Xác nhận</button>
                                              </form>

                                          </div>

                                      </div>
                                  </div>
                              </div> <?php } ?>
                                           
                          </header>
                          <div class="panel-body">
                                <div class="adv-table">
                                    <table  class="display table table-bordered table-striped table-hover" id="example">
                                      <thead>
                                      <tr>
                                          <th>ROLE_ID</th>
                                          <th>USERNAME</th>
                                          <th>EMAIL</th>
                                          <th>FULL_NAME</th>
                                          <th>FACEBOOK</th>
                                          <th>STEAM_PROFILE</th>
                                          <th>STEAMOFFER_URL</th>
                                          <th>ADDRESS</th>
                                          <th>PHONE_NUMBER</th>
                                          <th>AVATAR</th>
                                          <th>WALLET</th>
                                          
                                      </tr>
                                      </thead>
                                      <tbody> <?php if(isset($list))
                                      { 
                                            foreach($list as $i) {
                                        ?>
                                      <tr class="gradeX">               
                                          <td><?php  $qu = $this->m_account->get_info_role_by_id($i->ROLE_ID);
                                            echo $qu->ROLE_NAME;



                                           ?></td>
                                          <td><?php echo $i->USERNAME ?> <?php      if($this->session->userdata('role') == 1) { ?>
                                          <a href="<?php echo base_url('account/update_account/'.$i->ACCOUNT_ID) ?>"><button style="float: right;" class="btn btn-success btn-xs"><i class="icon-pencil"></i></button></a>
                                          <?php } ?>
                                          </td>
                                          <td><?php echo $i->EMAIL ?></td>
                                          <td><?php echo $i->FULL_NAME ?></td>
                                          <td><?php echo $i->FACEBOOK ?></td>
                                          <td><?php echo $i->STEAM_PROFILE ?></td>
                                          <td><?php echo $i->STEAMOFFER_URL ?></td>
                                          <td><?php echo $i->ADDRESS ?></td>
                                          <td><?php echo $i->PHONE_NUMBER ?></td>
                                          <td><?php echo $i->AVATAR ?></td>
                                          <td>
                                          <?php      if($this->session->userdata('role') == 1) { ?>
                                                  <a href="#myModal_<?php echo $i->ACCOUNT_ID ?>" data-toggle="modal" class="btn btn-xs btn-info">
                                            
                                                  <?php if($i->WALLET != '') echo $i->WALLET; else echo 'chưa có wallet' ?>
                                                 </a>  
                                                 <div aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" id="myModal_<?php echo $i->ACCOUNT_ID ?>" class="modal fade">
                                          <div class="modal-dialog">
                                              <div class="modal-content">
                                                  <div class="modal-header">
                                                      <button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
                                                      <h4 class="modal-title">Cập nhật wallet</h4>
                                                  </div>
                                                  <div class="modal-body">
        
                                                                  <form class="form-horizontal" method="POST" action="<?php echo base_url('account/cap_nhat_wallet') ?>" role="form">
                                                                      <div class="form-group">
                                                                          <label for="wallet_cu" class="col-lg-2 col-sm-2 control-label">Wallet cũ</label>
                                                                          <div class="col-lg-10">
                                                                              <input type="text" class="form-control" id="wallet_cu" value="<?php echo $i->WALLET ?>" readonly />
                                                                          </div>
                                                                      </div>
                                                                      <div class="form-group">
                                                                          <label for="wallet_moi" id="" class="col-lg-2 col-sm-2 control-label">Wallet mới</label>
                                                                          <div class="col-lg-10">
                                                                              <input type="hidden" name="account_id" value="<?php echo $i->ACCOUNT_ID ?>" />
                                                                              <input type="hidden" name="current" value="<?php echo current_url() ?>" />
                                                                              <input type="text" class="wallet form-control" id="wallet_moi" name="wallet_moi" placeholder="Nhập wallet mới" />
                                                                          </div>
                                                                      </div>
                                                                      <div class="form-group">
                                                                          <div class="col-lg-offset-2 col-lg-10">
                                                                              <button type="submit" onClick="alert('Cập nhật thành công')" class="btn btn-info">Cập nhật</button>
                                                                          </div>
                                                                      </div>
                                                                  </form>
        
                                                  </div>
        
                                              </div>
                                          </div>
                                      </div>  <?php } else if($i->WALLET != '') echo $i->WALLET; else echo 'chưa có wallet' ?>
                                          </td>
                                      </tr>  <?php } } ?>
                                      
                                      </tbody>
                          </table>
                                </div>
                          </div>
                      </section>
                  </div>
              </div>
              <!-- page end-->
          </section>
      </section>
      <!--main content end-->
      <!--footer start-->
      <footer class="site-footer">
           <?php $this->load->view('admin_layout/footer') ?>
      </footer>
      <!--footer end-->
  </section>

    <!-- js placed at the end of the document so the pages load faster -->
    <!--<script src="js/jquery.js"></script>-->
    <script type="text/javascript" language="javascript" src="<?php echo base_url() ?>Resources/Admin/assets/advanced-datatable/media/js/jquery.js"></script>
    <script src="<?php echo base_url() ?>Resources/Admin/js/bootstrap.min.js"></script>
    <script class="include" type="text/javascript" src="<?php echo base_url() ?>Resources/Admin/js/jquery.dcjqaccordion.2.7.js"></script>
    <script src="<?php echo base_url() ?>Resources/Admin/js/jquery.scrollTo.min.js"></script>
    <script src="<?php echo base_url() ?>Resources/Admin/js/jquery.nicescroll.js" type="text/javascript"></script>
    <script type="text/javascript" language="javascript" src="<?php echo base_url() ?>Resources/Admin/assets/advanced-datatable/media/js/jquery.dataTables.js"></script>
    <script src="<?php echo base_url() ?>Resources/Admin/js/respond.min.js" ></script>


  <!--common script for all pages-->
    <script src="<?php echo base_url() ?>Resources/Admin/js/common-scripts.js"></script>

    <!--script for this page only-->

      <script type="text/javascript" charset="utf-8">
          $(document).ready(function() {
              $('#example').dataTable( {
                  "aaSorting": [[ 4, "desc" ]]
              } );
          } );
      </script>
      <script type="text/javascript">
                                                		$(".wallet").keydown(function (e) {
                                                		//  alert('abc');
                                                		    // Allow: backspace, delete, tab, escape, enter and .
                                                		    if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 190]) !== -1 ||
                                                		         // Allow: Ctrl+A
                                                		        (e.keyCode == 65 && e.ctrlKey === true) || 
                                                		         // Allow: home, end, left, right
                                                		        (e.keyCode >= 35 && e.keyCode <= 39)) {
                                                		             // let it happen, don't do anything
                                                		             return;
                                                		    }
                                                		    // Ensure that it is a number and stop the keypress
                                                		    if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) {
                                                		        e.preventDefault();
                                                		    }
                                                		});
                                                	</script>
  </body>
</html>
